<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <%request.setCharacterEncoding("UTF-8"); %>
    <jsp:useBean id="student" class="com.wgh.student"></jsp:useBean>
    <jsp:setProperty property="*" name="student"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>保存学生信息</title>
  
</head>
<body>
<%
try{
      Class.forName("com.mysql.jdbc.Driver");		
		String url = "jdbc:mysql://localhost:3306/jsp";	
		String username = "root";							
		String password = "root";							
		Connection conn = DriverManager.getConnection(url,username,password);
		String sql = "insert into zhoujianyang(id,name,interesting,username,password) values(?,?,?,?,?)";
		PreparedStatement ps = conn.prepareStatement(sql);
		ps.setInt(1,student.getid());
		ps.setString(2,student.getname());
	    ps.setString(3,student.getinteresting());
	    ps.setString(4,student.getusername());
	    ps.setString(5,student.getpassword());
		int row = ps.executeUpdate();
		if(row > 0){
		     out.print("成功添加了"+row+"条数据!");
		     }
		     ps.close();
		     conn.close();
		     }catch(Exception e){
		     out.print("学生信息添加失败!");
		     e.printStackTrace();
		     }
		     %>
		     <br>
		     <a href="Login.jsp">返回</a>

</body>
</html>